package com.origin.sse.service;

import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

import java.util.List;

/**
 * Sse(server-send event)
 *
 * @author yezh
 * @date 2024/1/15 19:23
 */
public interface SseEmitterService {

    SseEmitter getSseConn(String clientId, List<String> eventTypeList);


    /**
     * 推送消息到客户端，此处结合业务代码，业务中需要推送消息处调用即可向客户端主动推送消息
     */
    void sendMsgToClient(String data, String eventType);

    /**
     * 推送消息到客户端
     * 此处做了推送失败后，重试推送机制，可根据自己业务进行修改
     */
    void sendMsgToClientByClientId(String clientId, String data, String eventType, SseEmitter sseEmitter);

    void closeSseConnect(String clientId);

}
